import java.util.Stack;

/**
 * add 操作：
 * 如果addSt不为空，直接追加即可；
 * 若为空，从popSt把数据压入addSt，再追加；
 * delete操作
 */
public class CQueue {

    private Stack<Integer> addSt;
    private Stack<Integer> popSt;


    public CQueue() {
        addSt = new Stack<Integer>();
        popSt = new Stack<Integer>();
    }

    public void appendTail(int value) {
        if (addSt.empty()) {
            while (!popSt.empty()){
                addSt.push(popSt.pop());
            }
        }
        addSt.push(value);

    }

    public int deleteHead() {

        if (popSt.empty()) {
            if (addSt.empty()) {
                return -1;
            }

            while (!addSt.empty()){
                popSt.push(addSt.pop());
            }
        }
        return popSt.pop();
    }

    public static void main(String[] args) {
//        Stack<Integer> addSt = new Stack<Integer>();
        CQueue obj = new CQueue();
        obj.appendTail(1);
        obj.appendTail(2);
        int n1 = obj.deleteHead();
        System.out.println(n1);
        int param_2 = obj.deleteHead();
        System.out.println(param_2);
        System.out.println(obj.deleteHead());
        System.out.println(obj.deleteHead());

    }

}
